import com.sun.istack.internal.NotNull;

/**
 * GetRawData类 getDeltaViewOfMembers方法中使用
 * 计算各个UP主的播放量增幅情况
 */
public class MembersView implements Comparable<MembersView> {
    private int view;
    private final String name;

    public MembersView(String name, int view) {
        this.name = name;
        this.view = view;
    }

    /**
     * 计算播放量增幅
     *
     * @param newView 月末播放量
     */
    public void deltaView(int newView) {
        view = newView - view;
    }

    /**
     * 添加UP主的名字和播放量增幅
     *
     * @param stringBuilder 添加到StringBuild里
     */
    public void addToStringBuilder(StringBuilder stringBuilder) {
        stringBuilder.append(name).append("（+").append(WriteReport.INT_FORMAT.format(view)).append("）\n");
    }

    /**
     * 用于排序
     *
     * @param another 另一个比较值
     * @return 返回比较结果
     */
    @Override
    public int compareTo(@NotNull MembersView another) {
        return another.view - view;
    }
}
